package com.ruoyi.project.tool.swagger.UserController;
import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysImg;
import com.ruoyi.project.system.service.ISysImgService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author theme
 * @date 2020-06-12
 */
@Api(description = "图片Controller" )
@RestController
@RequestMapping("/mobileUser/img" )
public class UserImgController extends BaseController {
    @Autowired
    private ISysImgService sysImgService;

    /**
     * 查询图片列表
     */
    @ApiOperation("查询图片列表" )
    @GetMapping("/list" )
    public TableDataInfo list(SysImg sysImg) {
        startPage();
        List<SysImg> list = sysImgService.selectSysImgList(sysImg);
        return getDataTable(list);
    }

    /**
     * 获取图片详细信息
     */
    @ApiOperation("获取图片详细信息" )
    @GetMapping(value = "/{imgId}" )
    public AjaxResult getInfo(@PathVariable("imgId" ) Long imgId) {
        return AjaxResult.success(sysImgService.selectSysImgById(imgId));
    }

    /**
     * 新增图片
     */
    @ApiOperation("新增图片" )
    @Log(title = "新增图片" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysImg sysImg) {
        return toAjax(sysImgService.insertSysImg(sysImg));
    }

    /**
     * 修改【请填写功能名称】
     */
    @ApiOperation("修改图片" )
    @Log(title = "修改图片" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysImg sysImg) {
        return toAjax(sysImgService.updateSysImg(sysImg));
    }

    /**
     * 删除【请填写功能名称】
     */
    @ApiOperation("删除图片" )
    @Log(title = "删除图片" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{imgId}" )
    public AjaxResult remove(@PathVariable Long imgId) {
        return toAjax(sysImgService.deleteSysImgById(imgId));
    }
}
